package com.example.bysj.Controller;
//201902104061徐中堂
import com.example.bysj.domain.GraduateProjectSource;

import com.example.bysj.Service.GraduateProjectSourceService;
import lombok.extern.slf4j.Slf4j;

import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@RestController
public class GraduateProjectSourceController {
    //生成一个实例
    @Resource
    private GraduateProjectSourceService graduateProjectSourceService;
    //查找全部
    @GetMapping("/graduateProjectSource.ctl")
    public List<GraduateProjectSource> findALL(){
        return graduateProjectSourceService.findAll();
    }
    //根据id查找
    @GetMapping("/graduateProjectSource.ctl/{id}")
    public GraduateProjectSource find(@PathVariable("id") int id){
        GraduateProjectSource graduateProjectSource = graduateProjectSourceService.find(id);
        if(graduateProjectSource!=null){
            return graduateProjectSource;
        }else {
            //自定义一个运行时异常
            throw new RuntimeException("未查询到 "+id+" !");
        }
    }
}
